package io;

import java.io.*;
import java.nio.charset.StandardCharsets;
import java.util.Scanner;

/*
缓冲字符流：写入
 */
public class PWDemo2 {
    public static void main(String[] args) throws FileNotFoundException {
        FileOutputStream fos=new FileOutputStream("pw.txt");//文件流（字节流，低级流）
        OutputStreamWriter osw=new OutputStreamWriter(fos, StandardCharsets.UTF_8);//字符转换流（字符流，高级流）
        BufferedWriter bw=new BufferedWriter(osw);//缓冲字符流（字符流，高级流）
        PrintWriter pw=new PrintWriter(bw,true);//按行读写

        Scanner scanner=new Scanner(System.in);
        System.out.println("请开始输入内容，输入exit退出");
        while (true){
            String line=scanner.nextLine();
            if (line.equals("exit")){
                break;
            }
            pw.println(line);


        }
        pw.close();

    }
}
